import { mapGetters } from 'vuex'

export default {
  data() {
    return {
      departmentAllListData: [],
      jobAllListData: [], // 用于下拉的所有职务数据
      regionAllListData: [], // 用于下拉的所有地区
      educationAllListData: [], // 用于下拉的所有学历
      bankAllListData: [], // 用于下拉的所有开户行
      politicalAllListData: [], // 用于下拉的所有政治面貌
      marryAllListData: [], // 用于下拉的婚姻状态
      nationAllListData: [], // 用于下拉的民族
      invoiceCompanyAllListData: [], // 用于开票公司的下拉
      uniformAllListData: [], // 用于工装列表下拉
      socialSecurityAccuracyListData: [], // 社保费用尾数处理
      employeePostLevelListData: [], // 员工职级列表
      employeeCompanyListData: [], // 所属公司
      listPlateBlockData: [] // 板块信息
    }
  },
  computed: {
    ...mapGetters('department', [
      'departmentList'
    ]),
    ...mapGetters('job', [
      'jobList',
      'listPlateBlock'
    ]),
    ...mapGetters('region', [
      'regionList'
    ]),
    ...mapGetters('dictionaries', [
      'educationList',
      'bankList',
      'politicalList',
      'marryList',
      'nationList',
      'invoiceCompanyList',
      'uniformList',
      'socialSecurityAccuracyList',
      'employeePostLevelList',
      'employeeCompanyList'
    ])
  },
  methods: {
    async getDepartmentAllListData() { // 获取所有数据
      try {
        await this.$store.dispatch('department/GetDepartmentList', {
          request: true
        })
      } catch (error) {
        // console.log(error)
        this.$notify.error({
          title: '错误',
          message: error.message
        })
      }
    },
    async getJobAllListData() { // 获取所有数据
      try {
        await this.$store.dispatch('job/GetJobList', {
          request: true
        })
      } catch (error) {
        // console.log(error)
        this.$notify.error({
          title: '错误',
          message: error.message
        })
      }
    },
    async getAllListPlateBlockData() { // 获取所有数据
      try {
        await this.$store.dispatch('job/GetListPlateBlockList', {
          request: true
        })
      } catch (error) {
        // console.log(error)
        this.$notify.error({
          title: '错误',
          message: error.message
        })
      }
    },
    async getRegionAllListData() { // 获取所有数据
      try {
        await this.$store.dispatch('region/GetRegionList', {
          request: false
        })
        // this.regionAllListData.push({
        //   id: '0',
        //   label: '中国'
        // }, {
        //   id: '',
        //   label: '中国'
        // })
      } catch (error) {
        // console.log(error)
        this.$notify.error({
          title: '错误',
          message: error.message
        })
      }
    },
    async getEducationAllListData() { // 获取所有数据
      try {
        await this.$store.dispatch('dictionaries/GetEducationList', {
          request: false,
          dictType: 'education'
        })
      } catch (error) {
        // console.log(error)
        this.$notify.error({
          title: '错误',
          message: error.message
        })
      }
    },
    async getBankAllListData() { // 获取所有数据
      try {
        await this.$store.dispatch('dictionaries/GetBankList', {
          request: false,
          dictType: 'bank'
        })
      } catch (error) {
        // console.log(error)
        this.$notify.error({
          title: '错误',
          message: error.message
        })
      }
    },
    async getPoliticalAllListData() { // 获取所有数据
      try {
        await this.$store.dispatch('dictionaries/GetPoliticalList', {
          request: false,
          dictType: 'political_status'
        })
      } catch (error) {
        // console.log(error)
        this.$notify.error({
          title: '错误',
          message: error.message
        })
      }
    },
    async getMarryAllListData() { // 获取所有数据
      try {
        await this.$store.dispatch('dictionaries/GetMarryList', {
          request: true,
          dictType: 'marry'
        })
      } catch (error) {
        // console.log(error)
        this.$notify.error({
          title: '错误',
          message: error.message
        })
      }
    },
    async getNationAllListData() { // 获取所有数据
      try {
        await this.$store.dispatch('dictionaries/GetNationList', {
          request: true,
          dictType: 'nation'
        })
      } catch (error) {
        // console.log(error)
        this.$notify.error({
          title: '错误',
          message: error.message
        })
      }
    },
    async getInvoiceCompanyListData() { // 获取所有数据
      try {
        await this.$store.dispatch('dictionaries/GetInvoiceCompanyList', {
          request: true,
          dictType: 'invoice_company'
        })
      } catch (error) {
        // console.log(error)
        this.$notify.error({
          title: '错误',
          message: error.message
        })
      }
    },
    async getUniformListData() { // 获取所有数据
      try {
        await this.$store.dispatch('dictionaries/GetUniformList', {
          request: true,
          dictType: 'hr_employee_clothes'
        })
      } catch (error) {
        // console.log(error)
        this.$notify.error({
          title: '错误',
          message: error.message
        })
      }
    },

    async GetSocialSecurityAccuracyList() { // 获取所有数据
      try {
        await this.$store.dispatch('dictionaries/GetSocialSecurityAccuracyList', {
          request: true,
          dictType: 'social_security_accuracy'
        })
      } catch (error) {
        // console.log(error)
        this.$notify.error({
          title: '错误',
          message: error.message
        })
      }
    },

    async GetEmployeePostLevelList() { // 获取所有数据
      try {
        await this.$store.dispatch('dictionaries/GetEmployeePostLevelList', {
          request: true,
          dictType: 'employee_post_level'
        })
      } catch (error) {
        // console.log(error)
        this.$notify.error({
          title: '错误',
          message: error.message
        })
      }
    },

    async getEmployeeCompanyList() { // 获取所有数据
      try {
        await this.$store.dispatch('dictionaries/getEmployeeCompanyList', {
          request: true,
          dictType: 'employee_company'
        })
      } catch (error) {
        // console.log(error)
        this.$notify.error({
          title: '错误',
          message: error.message
        })
      }
    }
  },

  watch: {
    'listPlateBlock': {
      handler: function(newVal, oldVal) {
        this.listPlateBlockData = newVal
      },
      deep: true,
      immediate: true
    },

    'employeeCompanyList': {
      handler: function(newVal, oldVal) {
        this.employeeCompanyListData = newVal
      },
      deep: true,
      immediate: true
    },

    'employeePostLevelList': {
      handler: function(newVal, oldVal) {
        console.log(newVal)
        this.employeePostLevelListData = newVal
      },
      deep: true,
      immediate: true
    },

    'socialSecurityAccuracyList': {
      handler: function(newVal, oldVal) {
        console.log(newVal)
        this.socialSecurityAccuracyListData = newVal
      },
      deep: true,
      immediate: true
    },

    // data , computed , props
    'invoiceCompanyList': {
      handler: function(newVal, oldVal) {
        console.log(newVal)
        this.invoiceCompanyAllListData = newVal
      },
      deep: true,
      immediate: true
    },
    'departmentList': {
      handler: function(newVal, oldVal) {
        this.departmentAllListData = newVal
      },
      deep: true,
      immediate: true
    },
    'jobList': {
      handler: function(newVal, oldVal) {
        this.jobAllListData = newVal
      },
      deep: true,
      immediate: true
    },
    'regionList': {
      handler: function(newVal, oldVal) {
        this.regionAllListData = newVal
      },
      deep: true,
      immediate: true
    },
    'educationList': {
      handler: function(newVal, oldVal) {
        this.educationAllListData = newVal
      },
      deep: true,
      immediate: true
    },
    'bankList': {
      handler: function(newVal, oldVal) {
        this.bankAllListData = newVal
      },
      deep: true,
      immediate: true
    },
    'politicalList': {
      handler: function(newVal, oldVal) {
        this.politicalAllListData = newVal
      },
      deep: true,
      immediate: true
    },
    'marryList': {
      handler: function(newVal, oldVal) {
        this.marryAllListData = newVal
      },
      deep: true,
      immediate: true
    },
    'nationList': {
      handler: function(newVal, oldVal) {
        this.nationAllListData = newVal
      },
      deep: true,
      immediate: true
    },
    'uniformList': {
      handler: function(newVal, oldVal) {
        this.uniformAllListData = newVal
      },
      deep: true,
      immediate: true
    }
  }
}
